package com.secsbrain.cmdb.client.iface;

import java.util.List;

import com.secsbrain.cmdb.client.model.App;
import com.secsbrain.cmdb.client.model.AppDetail;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.secsbrain.common.ResponseVo;
import com.secsbrain.cmdb.client.model.AppTypeDto;
import com.secsbrain.cmdb.client.model.BizType;

/**
 * 应用信息相关服务
 *
 * @author zhaoyi
 */
@FeignClient("service-cmdb")
public interface AppInfoService {

    /**
     * 功能描述: <br>
     * 通过应用Id查询应用信息
     *
     * @return
     */
    @RequestMapping(value = "/cmdbservice/queryAppById", method = RequestMethod.GET)
    ResponseVo<AppDetail> queryAppDetailById(@RequestParam("appId") Long appId);

    @RequestMapping(value = "/cmdbservice/queryAppDetailByIds", method = RequestMethod.GET)
    ResponseVo<List<AppDetail>> queryAppDetailByIds(@RequestParam("appIds") Long[] appIds);

    /**
     * 功能描述: <br>
     * 查询应用分类列表
     *
     * @return
     */
    @RequestMapping(value = "/cmdbservice/queryAppType", method = RequestMethod.GET)
    ResponseVo<List<AppTypeDto>> queryAppType();

    /**
     * 功能描述: <br>
     * 查询应用列表
     *
     * @return
     */
    @RequestMapping(value = "/cmdbservice/queryAllAppList", method = RequestMethod.GET)
    ResponseVo<List<App>> queryAllAppList(@RequestParam(value = "page", required = false) Integer page,
                                          @RequestParam(value = "limit", required = false) Integer limit,
                                          @RequestParam(value = "sortBy", required = false) String sortBy,
                                          @RequestParam(value = "descending", required = false) String descending,
                                          @RequestParam(value = "appName", required = false) String appName,
                                          @RequestParam(value = "systemType", required = false) String systemType);

    /**
     * 功能描述: <br>
     * 通过分类查询应用列表
     *
     * @param typeArray 应用类型，如XHX、KKL、EWT、PUB等
     * @return
     */
    @RequestMapping(value = "/cmdbservice/queryAppListByType", method = RequestMethod.GET)
    ResponseVo<List<App>> queryAppListByType(@RequestParam("typeArray") String[] typeArray);

    /**
     * 功能描述: <br>
     * 查询所有业务类型列表
     *
     * @return
     */
    @RequestMapping(value = "/cmdbservice/queryAllBizList", method = RequestMethod.GET)
    ResponseVo<List<BizType>> queryAllBizList();

    /**
     * 功能描述: <br>
     * 通过用户Id查询业务类型列表
     *
     * @return
     */
    @RequestMapping(value = "/cmdbservice/queryBizListByUserId", method = RequestMethod.GET)
    ResponseVo<List<BizType>> queryBizListByUserId(@RequestParam("userId") Long userId);

    /**
     * 功能描述: <br>
     * 是否是某应用的owner
     *
     * @param appId  应用ID
     * @param userId 用户ID
     * @return
     */
    @RequestMapping(value = "/cmdbservice/isOwner", method = RequestMethod.GET)
    ResponseVo<Boolean> isOwner(@RequestParam("appId") Long appId, @RequestParam("userId") Long userId);

    /**
     * 功能描述: <br>
     * 获取用户的owner下的业务信息
     *
     * @return
     */
    @RequestMapping(value = "/cmdbservice/getOwnerBiz", method = RequestMethod.GET)
    ResponseVo<List<BizType>> getOwnerBiz(@RequestParam("userId") Long userId);

    /**
     * 功能描述: <br>
     * 通过应用ID查询owner信息
     *
     * @return
     */
    @RequestMapping(value = "/cmdbservice/queryOwnerByAppId", method = RequestMethod.GET)
    ResponseVo<Long> queryOwnerByAppId(@RequestParam("appId") Long appId);

    /**
     * 功能描述: <br>
     * 通过应用ID查询质量负责人信息
     *
     * @return
     */
    @RequestMapping(value = "/cmdbservice/queryQualityByAppId", method = RequestMethod.GET)
    ResponseVo<Long> queryQualityByAppId(@RequestParam("appId") Long appId);

    /**
     * 功能描述: <br>
     * 根据环境名区分是否是线上环境
     */
    @RequestMapping(value = "/cmdbservice/queryEnvFlag", method = RequestMethod.GET)
    ResponseVo<String> queryEnvFlag(@RequestParam("envName") String envName);

}
